<?php
include "ReaderXML.class.php";
include "RenderLayerXML.class.php";
include "RenderMapXML.class.php";
include "GThaiParser.class.php";

$path = $_SERVER['PATH_INFO'];
if ($path != null)
{
  $path_param = spliti("/", $path);
  switch ($path_param[1])
  {
    case "layer":
      $layer = new RenderLayerXML();
      $layer->genFloodLayerXML();
      break;
    case "map":
      $id = $path_param[2];
      
//      foreach (DBConnect::query(
//      "SELECT m.id,m.name,m.icon,m.link,m.cr_date,m.lu_date FROM gthai.gthai_layer AS m WHERE m.id = $id") as $row)
//      {
//        $xml = $row['link'];
//        $icon = $row['icon'];
//        $reference = $row['name'];
//      }
      $rssGMap = new GThaiParser($id);
      if ($id == 7)
      {
        $result = $rssGMap->getReadUshahidiXML();
      }
      else
      {
        $result = $rssGMap->xmlReader();
      }
      $map = new RenderMapXML();
      $map->genFloodMapXML($result);
      break;
    default:
      break;
  }
}
?>